Skip to content

feat: add regex support to trusted-origins#7697

Merged
code-asher merged 3 commits intocoder:mainfrom
abdulsattar:feat/trusted-origins-regex
Mar 25, 2026
Merged

feat: add regex support to trusted-origins#7697
code-asher merged 3 commits intocoder:mainfrom
abdulsattar:feat/trusted-origins-regex

Conversation

@abdulsattar
Copy link
Contributor

Summary

Adds regex support for --trusted-origins. Entries can be exact host strings, *, or regex literals in the form /pattern/flags (e.g. /^.*\.example\.com$/i).

Changes

  • Add isTrustedOrigin() helper that matches exact strings, *, or regex literals /pattern/flags. Invalid regex entries are treated as non-matching.
  • Use isTrustedOrigin in authenticateOrigin() for --trusted-origins (VS Code WebSocket and path/domain proxy).
  • Add unit tests for isTrustedOrigin and for regex/wildcard in the origin auth flow.

Use case

Useful when code-server is behind a wildcard subdomain (e.g. --trusted-origins '/\.your-domain\.com$/') so you don't have to list every subdomain explicitly.

Made with Cursor

- Add isTrustedOrigin() helper that matches exact strings, '*', or regex
  literals in the form /pattern/flags (e.g. /^.*\.example\.com$/i)
- Use isTrustedOrigin in authenticateOrigin() for --trusted-origins
- Add unit tests for isTrustedOrigin and for regex/wildcard in origin auth

Made-with: Cursor
@abdulsattar abdulsattar requested a review from a team as a code owner March 9, 2026 18:53
@abdulsattar
Copy link
Contributor Author

Apologies for raising an AI PR, but I reviewed it thoroughly. We run a Websocket server on the instance and we want to use the proxy to connect to it from several domains.

Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

- Match --proxy-domain prior art: exact, *, or *.example.com style
- Remove full regex support; simpler to type and read

Made-with: Cursor
Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, but thank you! This is awesome.

@code-asher code-asher merged commit 4d615f1 into coder:main Mar 25, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants